package com.fenyin.samples.study.parttern.struct.adapter.example2;  

import java.util.Iterator;
import java.util.StringTokenizer;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
 *@Title:  类适配器模式
 *<p>StringTokenizerIterator：适配器类</p>
 *<p>StringTokenizer：适配器源类</p>
 *<p>Iterator：适配器目标接口</p>
 *@Author:fengzhichao  
 *@Since:2012-9-29  
 *@Version:1.1.0
 */
public class StringTokenizerIterator extends StringTokenizer implements Iterator<String>{

	private static final Log log = LogFactory.getLog(StringTokenizerIterator.class);
	
	public StringTokenizerIterator(String str, String delim) {
		super(str, delim);  
	}

	public boolean hasNext() {
		return super.hasMoreElements();
	}

	public String next() {
		return (String) super.nextElement();
	}

	public void remove()throws UnsupportedOperationException{
		throw new UnsupportedOperationException("Not supported");
	}
	
	public static void main(String[] args){
		Iterator<String> iterator = new StringTokenizerIterator("name=fzc#age=18","#");
		while(iterator.hasNext()){
			log.info("数据元素:"+iterator.next());
		}
	}
}
